# -*- coding: utf-8 -*-

from odoo import fields, api
from odoo_contrib import models as contrib_models


class ExhibitVisitHistory(contrib_models.SchemaModel):
    _name = 'exhibition.exhibit_visit_history'
    _description = 'Exhibit visit history'
    _order = 'create_date desc'

    wechat_uid = fields.Many2one(
        'wechat.user',
        required=True,
        string='微信用户id',
    )
    exhibit_id = fields.Many2one(
        'exhibition.exhibit',
        required=True,
        string='展品id',
    )

    wechat_user_openid = fields.Char(string='用户openid', related='wechat_uid.openid')
    wechat_user_nickname = fields.Char(string='用户昵称', related='wechat_uid.nickname')
    wechat_user_avatar = fields.Char(string='用户头像', related='wechat_uid.avatar')

    exhibit_name = fields.Char(string='展品名称', related='exhibit_id.name')
    exhibit_code = fields.Char(string='展品编号', related='exhibit_id.code')
